/*
 * @Author: your name
 * @Date: 2022-01-11 17:55:22
 * @LastEditTime: 2022-01-11 18:35:26
 * @LastEditors: your name
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \campus-market-frontend-master\src\util\index.ts
 */
import { User } from "../services/auth"
/**
 * 封装日期格式化方法
 * @param datastring
 */
export function dataFormat(datastring: string): string {
  const Data = new Date(datastring)
  function p(s: number) {
    return s < 10 ? '0' + s : s
  }
  const resDate =
    Data.getFullYear() +
    '年' +
    p(Data.getMonth() + 1) +
    '月' +
    p(Data.getDate()) +
    '日'
  const resTime =
    p(Data.getHours()) +
    ':' +
    p(Data.getMinutes()) +
    ':' +
    p(Data.getSeconds())
  return resDate + resTime
}
/**
 * 对User对象日期的封装
 * @param User
 * @returns
 */
export function UserDateFormat(User:User) : User{
  User.profile.createdAt = dataFormat(User.profile.createdAt)
  User.profile.updatedAt = dataFormat(User.profile.updatedAt)
  return User
}
